package model.schedule;

import java.sql.ResultSet;
import java.sql.SQLException;

import model.database.CalendarWrapper;
import model.database.Database;

public abstract class Ad implements Comparable<Ad> {
	protected CalendarWrapper enddate;
	protected int adId;
	protected Database database;
	protected int thisId;
	protected String title;

	protected Ad(ResultSet rs, Database database) {
		try {
			this.adId = rs.getInt("id");
			this.thisId = rs.getInt("thisId");
			this.enddate = new CalendarWrapper();
			this.enddate.setTime(rs.getTimestamp("enddate").getTime());
			this.database = database;
			this.title = rs.getString("title");
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	public int getId() {
		return this.adId;
	}
	
	public String getTitle() {
		return this.title;
	}

	public CalendarWrapper getEnd() {
		return this.enddate;
	}
	
	public int compareTo(Ad arg0) {
		return arg0.getEnd().compareTo(this.getEnd());
	}
	
	public abstract void handle();	
}
